package com.iris.live.services.data.repositories;

import com.iris.live.services.data.models.VirtualStockModel;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by ThinkPad on 2016/9/2
 */
@Transactional
public interface VirtualStockModelRepository extends JpaRepository<VirtualStockModel, Integer>, JpaSpecificationExecutor<VirtualStockModel> {
    @Modifying
    @Query("update VirtualStockModel set id = id + 1 where value = 'IRISTechnologies' ")
    void setNewVirtualStockCode();

    @Query("select id from VirtualStockModel where value = 'IRISTechnologies' ")
    Integer getVirtualStockCode();
}
